package com.shaozi.nc.data.mongodao;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.stereotype.Repository;

import com.shaozi.lib.throwable.SzException;
import com.shaozi.nc.bean.resp.ReqSecretaryTypeBadgeBean;
import com.shaozi.nc.bean.resp.ReqSecretaryUnreadMessageTotalBean;
import com.shaozi.nc.bean.resp.RespBriefReportTypeBadgeBean;
import com.shaozi.nc.bean.resp.RespBriefReportUnreadMessageTotalBean;
import com.shaozi.nc.data.model.BriefReportModel;
import com.shaozi.nc.data.model.SecretaryModel;


@Repository("briefReportMDao")
public class BriefReportMDao extends BaseSecretaryMDao<BriefReportModel> {

	@Autowired
	public BriefReportMDao(MongoTemplate shaoziTemplate) {
		super(shaoziTemplate);
	}

	@Override
	protected Class getClassSon() {
		return BriefReportModel.class;
	}

	@Override
	public Map getTypeBadge(ReqSecretaryTypeBadgeBean reqBean) throws SzException {
		Map<String, RespBriefReportTypeBadgeBean> ret = new HashMap<>();
		commonGetTypeBadge(ret, reqBean, SecretaryModel.class);
		return ret;
	}
	
	@Override
	public RespBriefReportUnreadMessageTotalBean unreadMessageTotal(ReqSecretaryUnreadMessageTotalBean reqBean) throws SzException {
		SecretaryModel model = findOneByParams(reqBean);
		if (model == null)
			return null;
		RespBriefReportUnreadMessageTotalBean respBean = new RespBriefReportUnreadMessageTotalBean();
		respBean.setBriefReport((BriefReportModel) model);
		int count = unreadMessageTotalCount(reqBean);
		respBean.setCount(count);
		return respBean;
	}
}
